<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('教师列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>教师编码：</label>
                                <input type="text" name="teacherCode"/>
                            </li>
                            <li>
                                <label>教师姓名：</label>
                                <input type="text" name="teacherName"/>
                            </li>
                            <li>
                                <label>教师专业：</label>
                                <input type="text" name="professional"/>
                            </li>
                            <li>
                                <label>教师教龄：</label>
                                <input type="text" name="teachAge"/>
                            </li>
                            <li>
                                <label>职称编码：</label>
                                <input type="text" name="titleCode"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:teacher:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:teacher:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:teacher:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:teacher:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:teacher:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:teacher:remove')}]];
        var prefix = ctx + "system/teacher";

        $(function() {
            var options = {
                url: prefix + "/list",
                //showUrl: prefix + "/show",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "教师",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'teacherId',
                    title: '教师ID',
                    visible: false
                },
                {
                    field: 'teacherCode',
                    title: '教师编码'
                },
                {
                    field: 'teacherName',
                    title: '教师姓名'
                },
                {
                    field: 'professional',
                    title: '教师专业'
                },
                {
                    field: 'teachAge',
                    title: '教师教龄'
                },
                {
                    field: 'teacherPicture',
                    title: '证件照',
                    formatter: function (value, row, index) {
                        let imgsrc = "";
                        $.ajax({
                            type: "POST",
                            url: "/system/teacher/show",
                            data: {"fileName": value},
                            async:false,
                            success: function (data) {
                                /*alert(data.url);*/
                                imgsrc = data.url;

                            /*<a id="url"><img th:src="@{src}" style="width: 90px;height: 90px"></a>*/
                            }
                        });
                        //alert(data.url);
                        return '<img src="' + imgsrc + '" width="50" height="50">';
                    }
                    /*$.post("/system/teacher/show",{"fileName":value},function(data){
                            value=data.url;
                            //console.log(value);
                        },"json");
                        var value=data.url;
                        return '<img src="' + value + '" width="50" height="50">';
                    }*/
                },
                {
                    field: 'titleCode',
                    title: '职称编码'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.teacherId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.teacherId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        /*var pic="";
        jQuery.ajax({
            type: "POST",
            url: ctx + "common/show",
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            dataType: 'json',
            success: function (result) {

              pic = result.url;

                //弹出测试
                //alert(JSON.stringify(result))
                //if (result.code == web_status.SUCCESS) {
                    //$("#url img").attr("src",result.url)
                    //$("#pic").val(result.url)
               // }
            },
            error: function (error) {
                alert("图片路径错误。");
            }
        });*/

    </script>
</body>
</html>